﻿#include<iostream>
using namespace std;

const int N = 100010;
int n, m, x;
int a[N], b[N];

int main() 
{
	cin >> n >> m >> x;
	for (int i = 0; i < n; i++) cin >> a[i];	
	for (int i = 0; i < m; i++) cin >> b[i];
		
	/*
	i指针指向数组的首，j指针指向数组的尾，
	a[i]+b[j]>x时，j指针向前一位移动，判断是否满足，不满足的话，i指针向后移动
	重复上述操作，直到满足条件为止
	*/
	for (int i = 0, j = m - 1; i < n; i++) 
	{
		while (j >= 0 && a[i] + b[j] > x) j--;
		if (a[i] + b[j] == x) 
		{
			cout << i << " " << j;
		}
	}	
	system("pause");
	return 0;
};